package luogu.hash;
//P1097 [NOIP2007 提高组] 统计数字

import java.util.*;

/**
 * @author :chenjie
 * @date :Created 2023/1/3 14:28
 */
public class Statistics {
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();
        Set<Integer> set=new TreeSet<>();
        Map<Integer,Integer>map=new TreeMap<>();
        for (int i = 0; i < n; i++) {
            int x=sc.nextInt();
            set.add(x);
            if(map.containsKey(x)){
                map.put(x,map.get(x)+1);
            }else {
                map.put(x,1);
            }
        }
        for (Integer integer : set) {
            System.out.println(integer+" "+map.get(integer));
        }
    }
}
